package com.gitee.absolute_spirit.hiot_android.ui.light

import androidx.lifecycle.ViewModel
import com.gitee.absolute_spirit.hiot_android.data.source.network.DeviceNetworkRepository
import com.gitee.absolute_spirit.hiot_android.data.source.proto.DataStoreRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import javax.inject.Inject

data class SwitchViewState(
    var on: Boolean = false
)

@HiltViewModel
class SwitchViewModel @Inject constructor(
    private val deviceNetworkRepository: DeviceNetworkRepository,
    private val dataStoreRepository: DataStoreRepository,
) : ViewModel() {
    private var _uiState = MutableStateFlow(SwitchViewState())
    var uiState = _uiState.asStateFlow()

    fun changeOnOffState() {
        _uiState.update {currentState ->
            currentState.copy(
                on = !currentState.on
            )
        }
    }
}